Skip to content

Conversation

@PingLiuPing
Copy link
Collaborator

Add Iceberg partition path utility for partition path naming.
Introduces IcebergPartitionPath, a utility class that converts partition keys to
their string representations for use in Iceberg partition directory paths.
The implementation follows the behavior of the Apache Iceberg Java library.

@netlify
Copy link

netlify bot commented Nov 7, 2025

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 2dee873
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/690fb485febddc0008c9ef93

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 7, 2025
std::string toPartitionString(int32_t value, const TypePtr& type)
const override;

/// Converts a Timestamp partition key to its string representation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converts a Timestamp partition key to its string representation.

This sentence is redundant. Consider dropping.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks


namespace facebook::velox::connector::hive::iceberg {

constexpr int32_t kEpochYear = 1970;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this into the only function where it is used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

if (type->isDate()) {
return DATE()->toString(value);
}
return folly::to<std::string>(value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fmt::to_string

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

}
}

std::string IcebergPartitionPath::toPartitionString(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps, add a check for transform type. I assume it must be kIdentity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right

EXPECT_EQ(
test(
TransformType::kIdentity,
StringView("\x48\x65\x6c\x6c\x6f"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding helper method testVarbinary that takes a single std::string argument. This will make code shorter and easier to read and allow testing long strings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion.


TEST(IcebergPartitionPathTest, identityTimestamp) {
EXPECT_EQ(
test(TransformType::kIdentity, Timestamp(0, 0), TIMESTAMP()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add testTimestamp helper method that takes a single Timestamp argument

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.


TEST(IcebergPartitionPathTest, truncateString) {
EXPECT_EQ(
test(TransformType::kTruncate, StringView("abc"), VARCHAR()), "abc");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume tranform type doesn't matter here. The results would be the same for kIdentity and kTruncate. If so, consider adding a helper method testString(std::string) which converts string using kIdentity and kTruncate, assert that results are the same and returns that result.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
I added a helper function testString.

namespace {

template <typename T>
std::string test(TransformType transform, T value, const TypePtr& type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are not testing anything here, let's rename to something like toPath.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@PingLiuPing PingLiuPing force-pushed the lp_iceberg_partition_path branch from 219ec2a to 2dee873 Compare November 8, 2025 21:22
return value.toString(options);
}

std::string IcebergPartitionPath::toPartitionString(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps, add a check for transformType here as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbasmanova Sorry I missed this comment. Will fix this in next PR.

}

std::string testInteger(int32_t value) {
auto identity = toPath(TransformType::kIdentity, value, INTEGER());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consistency: identity vs. identityResult, trunc vs. truncateResult

please, unify

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this comment. Will fix this in next PR.

Copy link
Contributor

@mbasmanova mbasmanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@mbasmanova mbasmanova added the ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall label Nov 10, 2025
@PingLiuPing
Copy link
Collaborator Author

@peterenescu Could you please help to import this PR? Thank you.

@meta-codesync
Copy link

meta-codesync bot commented Nov 10, 2025

@peterenescu has imported this pull request. If you are a Meta employee, you can view this in D86686298.

@meta-codesync
Copy link

meta-codesync bot commented Nov 10, 2025

@peterenescu merged this pull request in 51d4a94.

PingLiuPing added a commit to IBM/velox that referenced this pull request Nov 11, 2025
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 11, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 854) Iceberg staging hub commit 1/14 - 26324ec
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 11, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 854) Iceberg staging hub commit 1/14 - 26324ec
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 11, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 854) Iceberg staging hub commit 1/14 - 26324ec
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 12, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 854) Iceberg staging hub commit 1/14 - 26324ec
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 12, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 854) Iceberg staging hub commit 1/14 - 26324ec
PingLiuPing added a commit to IBM/velox that referenced this pull request Nov 12, 2025
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 12, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 854) Iceberg staging hub commit 1/14 - 26324ec
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 12, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 860) Iceberg staging hub commit 1/13 - 20dee14
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 13, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 860) Iceberg staging hub commit 1/13 - 20dee14
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 13, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 860) Iceberg staging hub commit 1/13 - 20dee14
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 13, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 860) Iceberg staging hub commit 1/13 - 20dee14
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 13, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 860) Iceberg staging hub commit 1/13 - 20dee14
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 14, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 860) Iceberg staging hub commit 1/13 - 20dee14
PingLiuPing added a commit to IBM/velox that referenced this pull request Nov 14, 2025
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 14, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 864) Iceberg staging hub commit 2/14 - 7a462c0
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 14, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 864) Iceberg staging hub commit 2/14 - 7a462c0
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 14, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 864) Iceberg staging hub commit 2/14 - 7a462c0
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 16, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 864) Iceberg staging hub commit 2/14 - 7a462c0
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 16, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 864) Iceberg staging hub commit 2/14 - 7a462c0
FelixYBW pushed a commit to IBM/velox that referenced this pull request Nov 16, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 864) Iceberg staging hub commit 2/14 - 7a462c0
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 16, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 864) Iceberg staging hub commit 2/14 - 7a462c0
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 16, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 864) Iceberg staging hub commit 2/14 - 7a462c0
PingLiuPing added a commit to IBM/velox that referenced this pull request Nov 17, 2025
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 17, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 885) Iceberg staging hub commit 3/15 - 112ce8a
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 17, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 885) Iceberg staging hub commit 3/15 - 112ce8a
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 17, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 885) Iceberg staging hub commit 3/15 - 112ce8a
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 18, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 885) Iceberg staging hub commit 3/15 - 112ce8a
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 18, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 885) Iceberg staging hub commit 3/15 - 112ce8a
prestodb-ci pushed a commit to IBM/velox that referenced this pull request Nov 18, 2025
…incubator#15443)"

This reverts commit 51d4a94.

Alchemy-item: (ID = 885) Iceberg staging hub commit 3/15 - 112ce8a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants